package geektime.spring.springbucks;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.List;

@Slf4j
@EnableTransactionManagement
@SpringBootApplication
public class SpringBucksApplication implements ApplicationRunner {
	@Autowired
	private JdbcTemplate jdbcTemplate;

	public static void main(String[] args) {
		SpringApplication.run(SpringBucksApplication.class, args);
	}

	@Override
	public void run(ApplicationArguments args) throws Exception {
		String sql1 = "select * from t_coffee where id = '1'";
		jdbcTemplate.execute(sql1);
		String sql2 = "select * from t_coffee where id = '1';select * from t_coffee where id = '2'";
		jdbcTemplate.execute(sql2);
		String sql3 = "select * from t_coffee where id in ('1','2','3','4','5')";
		jdbcTemplate.execute(sql3);
		String sql4 = "select * from t_coffee where id in ('1','2','3','4','5','6','7','8','9','10','11')";
		jdbcTemplate.execute(sql4);
	}
}

